﻿using System;

namespace OperationPlugins.Handlers
{
    public abstract class AbstractHandler : ContextualPlugin, IHandler
    {
        /// <summary>
        /// Performs the handling.
        /// </summary>
        protected abstract void Handle();

        /// <summary>
        /// Handles an object.
        /// </summary>
        /// <param name="value">The object to be handled.</param>
        /// <param name="context">The operation context.</param>
        void IHandler.Handle(object value, OperationContext context)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            Value = value;

            Context = context;

            Handle();
        }

    }
}
